package ijen.fbconnect.services;

import ijen.fbconnect.FBRequest;

/**
 * Description of AuthSimple.
 * Simple service class to simply some 'auth' API access;
 * ---------------------------------------------------------------------------------------
 * User: fred
 * Date: Jul 22, 2009
 * Time: 1:08:03 PM
 * ---------------------------------------------------------------------------------------
 */
public class FBAuthService extends FBAbstractService {


    /**
     * <p>Request a new auth token.
     * @return Configured FBRequest
     */
    public FBRequest createToken() {
        return new FBRequest(session, "facebook.auth.createToken");
    }

    
    /**
     * <p>Request a new session (after login) with an auth token.
     * <p>Note that one can still use 'special' tokens to acquire an infinite session.
     * @param pToken Auth token
     * @return Configured FBRequest
     */
    public FBRequest getSession(final String pToken) {

        FBRequest result = new FBRequest("facebook.auth.getSession");

        result.getParameters().put("auth_token", pToken);

        if (session.getApplicationSecret() == null) {
            result.getParameters().put("generate_session_secret", "1");
        }

        return result;
    }


}
